﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace XmlDSigEx
{
    class CanonicalisationProvider:ICanonicalisationProvider
    {
        public bool CanHandle(string uri)
        {
            return uri.StartsWith(XmlC14NCanonicalisation.URI_C14N) ||
                uri.StartsWith(ExcXmlC14NCanonicalisation.URI_EXC_C14N);
        }

        public ICanonicalisationAlgorithm GetCanonicalisation(string uri)
        {
            switch (uri)
            {
                case XmlC14NCanonicalisation.URI_C14N:
                    return new XmlC14NCanonicalisation();

                case ExcXmlC14NCanonicalisation.URI_EXC_C14N:
                    return new ExcXmlC14NCanonicalisation();

                case ExcXmlC14NCanonicalisation.URI_EXC_C14N + "WithComments":
                    return new ExcXmlC14NCanonicalisation();

                default:
                    throw new ArgumentException("Incorrect uri for this Provider.");
            }
        }
    }
}
